package com.xiaobug.demo;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.ljb.commlibrary.utils.L;
import com.xiaobug.baselibrary.base.BaseActivity;
import com.xiaobug.demo.alipay.AlipayActivity;
import com.xiaobug.demo.databinding.MainActivityBinding;
import com.xiaobug.demo.glide.GlideTestActivity;
import com.xiaobug.demo.loadsir.LoadsirActivity;
import com.xiaobug.demo.navigation.BottomNavigationActivity;
import com.xiaobug.demo.okgo.OkgoTestActivity;
import com.xiaobug.demo.oss.OssTestActivity;

import java.lang.reflect.Type;

public class MainActivity extends BaseActivity<MainActivityBinding> {
    public class Presenter {
        public void onClick1(View view) {
            OssTestActivity.actionStart(MainActivity.this);
        }

        public void onClick2(View view) {
            OkgoTestActivity.actionStart(MainActivity.this);
        }

        public void onClick3(View view) {
            GlideTestActivity.actionStart(MainActivity.this);
        }

        public void onClick4(View view) {
            startActivity(BottomNavigationActivity.class);
        }

        public void onClick5(View view) {
            startActivity(LoadsirActivity.class);
        }

        public void onClick6(View view) {
            testGaon();
        }

        public void onClick7(View view) {
            startActivity(AlipayActivity.class);
        }

        public void onClick8(View view){
            startActivity(DragActivity.class);
        }
    }

    public static void actionStart(Context context) {
        context.startActivity(new Intent(context, MainActivity.class));
    }

    @Override
    protected int getRootID() {
        return R.layout.main_activity;
    }

    @Override
    protected void initData(Bundle savedInstanceState, MainActivityBinding mBinding) {
        mBinding.setP(new Presenter());
    }

    private void testGaon() {
        Gson gson = new Gson();
        User user = new User("怪盗kidou", 24, "2018年9月8日");

        Gson gson1 = new GsonBuilder()
                .serializeNulls()
                .setDateFormat("yyyy-MM-dd")
                .disableInnerClassSerialization()
                .generateNonExecutableJson()
                .disableHtmlEscaping()
                .setPrettyPrinting()
                .create();

        L.e(gson1.toJson(user));
    }

}
